package com.ddyx.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.ddyx.model.DeviceEventData;
import com.ddyx.service.IDeviceEventDataParser;

/**
 * 解析链
 * 
 * @author zhongchzh
 *
 */
public class DeviceEventDataParserChain implements IDeviceEventDataParser  {

	private List<IDeviceEventDataParser> parsers = new ArrayList<IDeviceEventDataParser>(3);
	
	@Override
	public DeviceEventData parse(JSONObject json) {
		for(IDeviceEventDataParser parser : parsers){
			DeviceEventData result = parser.parse(json);
			if(result != null) return result;
        }
		return null;
	}

	public List<IDeviceEventDataParser> getParsers() {
		return parsers;
	}

	public void setParsers(List<IDeviceEventDataParser> parsers) {
		this.parsers = parsers;
	}
}
